<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <meta name="ctx" th:content="${#httpServletRequest.getContextPath()}"/>
    <link rel="stylesheet" th:href="@{/css/admin/base-v2.css}">
    <link rel="stylesheet" th:href="@{/css/wlfb-font/css/iconfont.css}">
    <link rel="stylesheet" th:href="@{/css/admin/app.css}">
    <style>
        .app-card{
            background: none;
            box-shadow: none;
        }
        .app-card-head{
            margin-left: 0;
        }
        .app-card-body {
            margin-bottom: 30px;
            box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 10px 0px;
            background: #fff;
            padding: 24px 32px;
        }

        .app-page-content {
            padding: 20px 35px;
        }

        .info {
            display: flex;
        }

        .info-item {
            flex: 1;
            text-align: center;
        }

        .info-item span {
            color: #333;
            font-size: 24px;
        }

        .info-item a span:hover {
            color: #108ee9;
        }

        .link {
            overflow: hidden;
        }

        .link-group {
            margin-bottom: 20px;
            float: left;
            width: 50%;
        }

        .link-group-title {
            color: #333;
            font-size: 16px;
            margin-bottom: 15px;
        }

        .link-item {
            margin-right: 25px;
        }

        .link-item:hover {
            color: #108ee9;
        }

        .link-left,
        .link-right {
            width: 50%;
        }

        .link-left {
            padding-right: 20px;
        }

        .link-right {
            padding-left: 20px;
        }

        .entry .app-card-body {
            padding-bottom: 0;
        }

    </style>
</head>

<body>

<div class="app-page">

    <div class="app-page-content">

        <div class="app-card">
            <div class="app-card-head">
                <div class="border"></div>
                <div class="app-card-title">实时概况</div>
                <div class="app-card-subtitle">更新时间：<span th:text="${currentTime}"></span></div>
            </div>
            <div class="app-card-body">
                <div class="info">
                    <div class="info-item">
                        <p>节目总数</p>
                        <a th:href="@{/cpProgram/listByPage}"><span th:text="${programCount}"></span></a>
                    </div>
                    <div class="info-item">
                        <p>待审核节目数</p>
                        <a th:href="@{/cpProgram/listByPage}"><span th:text="${pendingCount}"></span></a>
                    </div>
                    <div class="info-item">
                        <p>联网终端数</p>
                        <a th:href="@{/cpDeviceInfo/listByPage}"><span th:text="${onlineDeviceCount}"></span></a>
                    </div>
                    <div class="info-item">
                        <p>离线终端数</p>
                        <a th:href="@{/cpDeviceInfo/listByPage}"><span th:text="${offlineDeviceCount}"></span></a>
                    </div>
                </div>
            </div>
        </div>

        <div class="entry app-card">
            <div class="app-card-head">
                <div class="border"></div>
                <div class="app-card-title">快速入口</div>
            </div>
            <div class="app-card-body">
                <div id="vue-app">
                    <div class="link">
                        <link-group v-for="item in menu.data" :group="item" :context="menu.context"></link-group>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

<script th:src="@{/lib/jquery.min.js}"></script>
<script th:src="@{/lib//vue/v2.5.16/vue.min.js}"></script>
<script th:src="@{/js/admin/home.js}"></script>
<script type="text/javascript" th:inline="javascript">
    //获取context path
    var context = $("meta[name='ctx']").attr("content") || '';
    //获取菜单列表
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: context +'/module/listMenuModule',
        data: {},
        cache: false,
        async: true,
        success: function (result) {
            data = result.data;
            //不显示首页
            for (var i = 0; i < data.length; i ++) {
                var obj = data[i];
                var url = obj["url"];
                if ("/cpweb/goCpHome" ==  url) {
                    data.splice(i, 1);
                    break;
                }
            }
            vueApp.menu = {
                data: data,
                context:context
            }
        }
    });

    // setTimeout(() => {
    //     // 菜单控件
    //     vueApp.menu = {
    //     context: '',
    //     data: [{
    //         label: '发布管理',
    //         children: [{
    //             label: '节目',
    //             url: "@{/发布管理-节目.html",
    //         }]
    //     },
    //         {
    //             label: '终端管理',
    //             children: [{
    //                 label: '终端',
    //                 url: "@{/终端-终端.html",
    //             }, {
    //                 label: 'apk',
    //                 url: "@{/终端-apk.html",
    //             }]
    //         },
    //     ],
    // }
    // }, 500);
</script>
</body>

</html>